﻿using System;
using System.Web.UI;
using Library.Logging;
using ITViet.Domains;
using System.Web.UI.WebControls;
using System.Collections.Generic;

namespace ITViet.Web.App_Code
{
  public class BaseControl : UserControl
  {
		public List<string[]> Hierarchy
		{
			get { return ((BasePage)Page).Hierarchy; }
			set { ((BasePage)Page).Hierarchy = value; }
		}

    public string SelectedMenuItem
    {
      get { return ((BasePage)Page).SelectedMenuItem; }
      set { ((BasePage)Page).SelectedMenuItem = value; }
    }

    public string SelectedMenuItemTitle
    {
      get { return ((BasePage)Page).SelectedMenuItemTitle; }
      set { ((BasePage)Page).SelectedMenuItemTitle = value; }
    }

    public string SelectedSubMenuItemTitle
    {
      get { return ((BasePage)Page).SelectedSubMenuItemTitle; }
      set { ((BasePage)Page).SelectedSubMenuItemTitle = value; }
    }

    public string SelectedSubMenuItem
    {
      get { return ((BasePage)Page).SelectedSubMenuItem; }
      set { ((BasePage)Page).SelectedSubMenuItem = value; }
    }

    protected string DefaultLoggingCategory
    {
      get { return BasePage.DefaultLoggingCategory; }
    }

    public Language CurrentLanguage
    {
      get { return ((BasePage)Page).CurrentLanguage; }
      set { ((BasePage)Page).CurrentLanguage = value; }
    }

    protected override void OnLoad(EventArgs e)
    {
      // Intentionally pauses server-side processing, to demonstrate the Loading Panel functionality.
      if (Page.IsCallback)
        System.Threading.Thread.Sleep(100);

      base.OnLoad(e);
    }

    #region Methods

    public void WriteLog(string description, Exception ex)
    {
      Logger.LogError(description, ex, DefaultLoggingCategory, null);
    }

    public string GetItemDescription(object status, string path)
    {
      return ((BasePage)(Page)).GetItemDescription(status, path);
    }
    #endregion
  }
}
